
<!DOCTYPE html>

<html>
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>pymatgen.analysis.diffraction.core &#8212; pymatgen 2020.7.3 documentation</title>
    <link rel="stylesheet" href="../../../../_static/basic.css" type="text/css" />
    <link rel="stylesheet" href="../../../../_static/pygments.css" type="text/css" />
    <script id="documentation_options" data-url_root="../../../../" src="../../../../_static/documentation_options.js"></script>
    <script src="../../../../_static/jquery.js"></script>
    <script src="../../../../_static/underscore.js"></script>
    <script src="../../../../_static/doctools.js"></script>
    <script src="../../../../_static/language_data.js"></script>
    <script async="async" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/latest.js?config=TeX-AMS-MML_HTMLorMML"></script>
    <link rel="index" title="Index" href="../../../../genindex.html" />
    <link rel="search" title="Search" href="../../../../search.html" />
 
<script type="text/javascript">
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-33990148-1']);
  _gaq.push(['_trackPageview']);
</script>

  </head><body>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../../../../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../../../../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="nav-item nav-item-0"><a href="../../../../index.html">pymatgen 2020.7.3 documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="../../../index.html" >Module code</a> &#187;</li>
          <li class="nav-item nav-item-2"><a href="../../../pymatgen.html" accesskey="U">pymatgen</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="">pymatgen.analysis.diffraction.core</a></li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
          <div class="body" role="main">
            
  <h1>Source code for pymatgen.analysis.diffraction.core</h1><div class="highlight"><pre>
<span></span><span class="c1"># coding: utf-8</span>
<span class="c1"># Copyright (c) Pymatgen Development Team.</span>
<span class="c1"># Distributed under the terms of the MIT License.</span>

<span class="sd">&quot;&quot;&quot;</span>
<span class="sd">This module implements core classes for calculation of diffraction patterns.</span>
<span class="sd">&quot;&quot;&quot;</span>

<span class="kn">import</span> <span class="nn">collections</span>
<span class="kn">import</span> <span class="nn">abc</span>
<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
<span class="kn">from</span> <span class="nn">pymatgen.core.spectrum</span> <span class="kn">import</span> <span class="n">Spectrum</span>
<span class="kn">from</span> <span class="nn">pymatgen.util.plotting</span> <span class="kn">import</span> <span class="n">add_fig_kwargs</span>


<div class="viewcode-block" id="DiffractionPattern"><a class="viewcode-back" href="../../../../pymatgen.analysis.diffraction.core.html#pymatgen.analysis.diffraction.core.DiffractionPattern">[docs]</a><span class="k">class</span> <span class="nc">DiffractionPattern</span><span class="p">(</span><span class="n">Spectrum</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    A representation of a diffraction pattern</span>
<span class="sd">    &quot;&quot;&quot;</span>

    <span class="n">XLABEL</span> <span class="o">=</span> <span class="s2">&quot;$2</span><span class="se">\\</span><span class="s2">Theta$&quot;</span>
    <span class="n">YLABEL</span> <span class="o">=</span> <span class="s2">&quot;Intensity&quot;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">hkls</span><span class="p">,</span> <span class="n">d_hkls</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Args:</span>
<span class="sd">            x: Two theta angles.</span>
<span class="sd">            y: Intensities</span>
<span class="sd">            hkls: [{&quot;hkl&quot;: (h, k, l), &quot;multiplicity&quot;: mult}],</span>
<span class="sd">                where {&quot;hkl&quot;: (h, k, l), &quot;multiplicity&quot;: mult}</span>
<span class="sd">                is a dict of Miller</span>
<span class="sd">                indices for all diffracted lattice facets contributing to each</span>
<span class="sd">                intensity.</span>
<span class="sd">            d_hkls: List of interplanar spacings.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">hkls</span><span class="p">,</span> <span class="n">d_hkls</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">hkls</span> <span class="o">=</span> <span class="n">hkls</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">d_hkls</span> <span class="o">=</span> <span class="n">d_hkls</span></div>


<div class="viewcode-block" id="AbstractDiffractionPatternCalculator"><a class="viewcode-back" href="../../../../pymatgen.analysis.diffraction.core.html#pymatgen.analysis.diffraction.core.AbstractDiffractionPatternCalculator">[docs]</a><span class="k">class</span> <span class="nc">AbstractDiffractionPatternCalculator</span><span class="p">(</span><span class="n">abc</span><span class="o">.</span><span class="n">ABC</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    Abstract base class for computing the diffraction pattern of a crystal.</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="c1"># Tolerance in which to treat two peaks as having the same two theta.</span>
    <span class="n">TWO_THETA_TOL</span> <span class="o">=</span> <span class="mf">1e-5</span>

    <span class="c1"># Tolerance in which to treat a peak as effectively 0 if the scaled</span>
    <span class="c1"># intensity is less than this number. Since the max intensity is 100,</span>
    <span class="c1"># this means the peak must be less than 1e-5 of the peak intensity to be</span>
    <span class="c1"># considered as zero. This deals with numerical issues where systematic</span>
    <span class="c1"># absences do not cancel exactly to zero.</span>
    <span class="n">SCALED_INTENSITY_TOL</span> <span class="o">=</span> <span class="mf">1e-3</span>

<div class="viewcode-block" id="AbstractDiffractionPatternCalculator.get_pattern"><a class="viewcode-back" href="../../../../pymatgen.analysis.diffraction.core.html#pymatgen.analysis.diffraction.core.AbstractDiffractionPatternCalculator.get_pattern">[docs]</a>    <span class="nd">@abc</span><span class="o">.</span><span class="n">abstractmethod</span>
    <span class="k">def</span> <span class="nf">get_pattern</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">structure</span><span class="p">,</span> <span class="n">scaled</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">two_theta_range</span><span class="o">=</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">90</span><span class="p">)):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Calculates the diffraction pattern for a structure.</span>

<span class="sd">        Args:</span>
<span class="sd">            structure (Structure): Input structure</span>
<span class="sd">            scaled (bool): Whether to return scaled intensities. The maximum</span>
<span class="sd">                peak is set to a value of 100. Defaults to True. Use False if</span>
<span class="sd">                you need the absolute values to combine XRD plots.</span>
<span class="sd">            two_theta_range ([float of length 2]): Tuple for range of</span>
<span class="sd">                two_thetas to calculate in degrees. Defaults to (0, 90). Set to</span>
<span class="sd">                None if you want all diffracted beams within the limiting</span>
<span class="sd">                sphere of radius 2 / wavelength.</span>

<span class="sd">        Returns:</span>
<span class="sd">            (DiffractionPattern)</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">pass</span></div>

<div class="viewcode-block" id="AbstractDiffractionPatternCalculator.get_plot"><a class="viewcode-back" href="../../../../pymatgen.analysis.diffraction.core.html#pymatgen.analysis.diffraction.core.AbstractDiffractionPatternCalculator.get_plot">[docs]</a>    <span class="k">def</span> <span class="nf">get_plot</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">structure</span><span class="p">,</span> <span class="n">two_theta_range</span><span class="o">=</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">90</span><span class="p">),</span>
                 <span class="n">annotate_peaks</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">ax</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">with_labels</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span>
                 <span class="n">fontsize</span><span class="o">=</span><span class="mi">16</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Returns the diffraction plot as a matplotlib.pyplot.</span>

<span class="sd">        Args:</span>
<span class="sd">            structure: Input structure</span>
<span class="sd">            two_theta_range ([float of length 2]): Tuple for range of</span>
<span class="sd">                two_thetas to calculate in degrees. Defaults to (0, 90). Set to</span>
<span class="sd">                None if you want all diffracted beams within the limiting</span>
<span class="sd">                sphere of radius 2 / wavelength.</span>
<span class="sd">            annotate_peaks: Whether to annotate the peaks with plane</span>
<span class="sd">                information.</span>
<span class="sd">            ax: matplotlib :class:`Axes` or None if a new figure should be created.</span>
<span class="sd">            with_labels: True to add xlabels and ylabels to the plot.</span>
<span class="sd">            fontsize: (int) fontsize for peak labels.</span>

<span class="sd">        Returns:</span>
<span class="sd">            (matplotlib.pyplot)</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">if</span> <span class="n">ax</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
            <span class="kn">from</span> <span class="nn">pymatgen.util.plotting</span> <span class="kn">import</span> <span class="n">pretty_plot</span>
            <span class="n">plt</span> <span class="o">=</span> <span class="n">pretty_plot</span><span class="p">(</span><span class="mi">16</span><span class="p">,</span> <span class="mi">10</span><span class="p">)</span>
            <span class="n">ax</span> <span class="o">=</span> <span class="n">plt</span><span class="o">.</span><span class="n">gca</span><span class="p">()</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="c1"># This to maintain the type of the return value.</span>
            <span class="kn">import</span> <span class="nn">matplotlib.pyplot</span> <span class="k">as</span> <span class="nn">plt</span>

        <span class="n">xrd</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_pattern</span><span class="p">(</span><span class="n">structure</span><span class="p">,</span> <span class="n">two_theta_range</span><span class="o">=</span><span class="n">two_theta_range</span><span class="p">)</span>

        <span class="k">for</span> <span class="n">two_theta</span><span class="p">,</span> <span class="n">i</span><span class="p">,</span> <span class="n">hkls</span><span class="p">,</span> <span class="n">d_hkl</span> <span class="ow">in</span> <span class="nb">zip</span><span class="p">(</span><span class="n">xrd</span><span class="o">.</span><span class="n">x</span><span class="p">,</span> <span class="n">xrd</span><span class="o">.</span><span class="n">y</span><span class="p">,</span> <span class="n">xrd</span><span class="o">.</span><span class="n">hkls</span><span class="p">,</span> <span class="n">xrd</span><span class="o">.</span><span class="n">d_hkls</span><span class="p">):</span>
            <span class="k">if</span> <span class="n">two_theta_range</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">&lt;=</span> <span class="n">two_theta</span> <span class="o">&lt;=</span> <span class="n">two_theta_range</span><span class="p">[</span><span class="mi">1</span><span class="p">]:</span>
                <span class="n">label</span> <span class="o">=</span> <span class="s2">&quot;, &quot;</span><span class="o">.</span><span class="n">join</span><span class="p">([</span><span class="nb">str</span><span class="p">(</span><span class="n">hkl</span><span class="p">[</span><span class="s2">&quot;hkl&quot;</span><span class="p">])</span> <span class="k">for</span> <span class="n">hkl</span> <span class="ow">in</span> <span class="n">hkls</span><span class="p">])</span>
                <span class="n">ax</span><span class="o">.</span><span class="n">plot</span><span class="p">([</span><span class="n">two_theta</span><span class="p">,</span> <span class="n">two_theta</span><span class="p">],</span> <span class="p">[</span><span class="mi">0</span><span class="p">,</span> <span class="n">i</span><span class="p">],</span> <span class="n">color</span><span class="o">=</span><span class="s1">&#39;k&#39;</span><span class="p">,</span>
                        <span class="n">linewidth</span><span class="o">=</span><span class="mi">3</span><span class="p">,</span> <span class="n">label</span><span class="o">=</span><span class="n">label</span><span class="p">)</span>
                <span class="k">if</span> <span class="n">annotate_peaks</span><span class="p">:</span>
                    <span class="n">ax</span><span class="o">.</span><span class="n">annotate</span><span class="p">(</span><span class="n">label</span><span class="p">,</span> <span class="n">xy</span><span class="o">=</span><span class="p">[</span><span class="n">two_theta</span><span class="p">,</span> <span class="n">i</span><span class="p">],</span>
                                <span class="n">xytext</span><span class="o">=</span><span class="p">[</span><span class="n">two_theta</span><span class="p">,</span> <span class="n">i</span><span class="p">],</span> <span class="n">fontsize</span><span class="o">=</span><span class="n">fontsize</span><span class="p">)</span>

        <span class="k">if</span> <span class="n">with_labels</span><span class="p">:</span>
            <span class="n">ax</span><span class="o">.</span><span class="n">set_xlabel</span><span class="p">(</span><span class="sa">r</span><span class="s2">&quot;$2\theta$ ($^\circ$)&quot;</span><span class="p">)</span>
            <span class="n">ax</span><span class="o">.</span><span class="n">set_ylabel</span><span class="p">(</span><span class="s2">&quot;Intensities (scaled)&quot;</span><span class="p">)</span>

        <span class="k">if</span> <span class="nb">hasattr</span><span class="p">(</span><span class="n">ax</span><span class="p">,</span> <span class="s2">&quot;tight_layout&quot;</span><span class="p">):</span>
            <span class="n">ax</span><span class="o">.</span><span class="n">tight_layout</span><span class="p">()</span>

        <span class="k">return</span> <span class="n">plt</span></div>

<div class="viewcode-block" id="AbstractDiffractionPatternCalculator.show_plot"><a class="viewcode-back" href="../../../../pymatgen.analysis.diffraction.core.html#pymatgen.analysis.diffraction.core.AbstractDiffractionPatternCalculator.show_plot">[docs]</a>    <span class="k">def</span> <span class="nf">show_plot</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">structure</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Shows the diffraction plot.</span>

<span class="sd">        Args:</span>
<span class="sd">            structure (Structure): Input structure</span>
<span class="sd">            two_theta_range ([float of length 2]): Tuple for range of</span>
<span class="sd">                two_thetas to calculate in degrees. Defaults to (0, 90). Set to</span>
<span class="sd">                None if you want all diffracted beams within the limiting</span>
<span class="sd">                sphere of radius 2 / wavelength.</span>
<span class="sd">            annotate_peaks (bool): Whether to annotate the peaks with plane</span>
<span class="sd">                information.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">get_plot</span><span class="p">(</span><span class="n">structure</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span><span class="o">.</span><span class="n">show</span><span class="p">()</span></div>

<div class="viewcode-block" id="AbstractDiffractionPatternCalculator.plot_structures"><a class="viewcode-back" href="../../../../pymatgen.analysis.diffraction.core.html#pymatgen.analysis.diffraction.core.AbstractDiffractionPatternCalculator.plot_structures">[docs]</a>    <span class="nd">@add_fig_kwargs</span>
    <span class="k">def</span> <span class="nf">plot_structures</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">structures</span><span class="p">,</span> <span class="n">fontsize</span><span class="o">=</span><span class="mi">6</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Plot diffraction patterns for multiple structures on the same figure.</span>

<span class="sd">        Args:</span>
<span class="sd">            structures (Structure): List of structures</span>
<span class="sd">            two_theta_range ([float of length 2]): Tuple for range of</span>
<span class="sd">                two_thetas to calculate in degrees. Defaults to (0, 90). Set to</span>
<span class="sd">                None if you want all diffracted beams within the limiting</span>
<span class="sd">                sphere of radius 2 / wavelength.</span>
<span class="sd">            annotate_peaks (bool): Whether to annotate the peaks with plane</span>
<span class="sd">                information.</span>
<span class="sd">            fontsize: (int) fontsize for peak labels.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="kn">import</span> <span class="nn">matplotlib.pyplot</span> <span class="k">as</span> <span class="nn">plt</span>
        <span class="n">nrows</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">structures</span><span class="p">)</span>
        <span class="n">fig</span><span class="p">,</span> <span class="n">axes</span> <span class="o">=</span> <span class="n">plt</span><span class="o">.</span><span class="n">subplots</span><span class="p">(</span><span class="n">nrows</span><span class="o">=</span><span class="n">nrows</span><span class="p">,</span> <span class="n">ncols</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">sharex</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span>
                                 <span class="n">squeeze</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>

        <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="p">(</span><span class="n">ax</span><span class="p">,</span> <span class="n">structure</span><span class="p">)</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="nb">zip</span><span class="p">(</span><span class="n">axes</span><span class="o">.</span><span class="n">ravel</span><span class="p">(),</span> <span class="n">structures</span><span class="p">)):</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">get_plot</span><span class="p">(</span><span class="n">structure</span><span class="p">,</span>
                          <span class="n">fontsize</span><span class="o">=</span><span class="n">fontsize</span><span class="p">,</span> <span class="n">ax</span><span class="o">=</span><span class="n">ax</span><span class="p">,</span> <span class="n">with_labels</span><span class="o">=</span><span class="n">i</span> <span class="o">==</span> <span class="n">nrows</span> <span class="o">-</span> <span class="mi">1</span><span class="p">,</span>
                          <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
            <span class="n">spg_symbol</span><span class="p">,</span> <span class="n">spg_number</span> <span class="o">=</span> <span class="n">structure</span><span class="o">.</span><span class="n">get_space_group_info</span><span class="p">()</span>
            <span class="n">ax</span><span class="o">.</span><span class="n">set_title</span><span class="p">(</span><span class="s2">&quot;</span><span class="si">{}</span><span class="s2"> </span><span class="si">{}</span><span class="s2"> (</span><span class="si">{}</span><span class="s2">) &quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">structure</span><span class="o">.</span><span class="n">formula</span><span class="p">,</span> <span class="n">spg_symbol</span><span class="p">,</span>
                                              <span class="n">spg_number</span><span class="p">))</span>

        <span class="k">return</span> <span class="n">fig</span></div></div>


<div class="viewcode-block" id="get_unique_families"><a class="viewcode-back" href="../../../../pymatgen.analysis.diffraction.core.html#pymatgen.analysis.diffraction.core.get_unique_families">[docs]</a><span class="k">def</span> <span class="nf">get_unique_families</span><span class="p">(</span><span class="n">hkls</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    Returns unique families of Miller indices. Families must be permutations</span>
<span class="sd">    of each other.</span>

<span class="sd">    Args:</span>
<span class="sd">        hkls ([h, k, l]): List of Miller indices.</span>

<span class="sd">    Returns:</span>
<span class="sd">        {hkl: multiplicity}: A dict with unique hkl and multiplicity.</span>
<span class="sd">    &quot;&quot;&quot;</span>

    <span class="c1"># TODO: Definitely can be sped up.</span>
    <span class="k">def</span> <span class="nf">is_perm</span><span class="p">(</span><span class="n">hkl1</span><span class="p">,</span> <span class="n">hkl2</span><span class="p">):</span>
        <span class="n">h1</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">abs</span><span class="p">(</span><span class="n">hkl1</span><span class="p">)</span>
        <span class="n">h2</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">abs</span><span class="p">(</span><span class="n">hkl2</span><span class="p">)</span>
        <span class="k">return</span> <span class="nb">all</span><span class="p">([</span><span class="n">i</span> <span class="o">==</span> <span class="n">j</span> <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">j</span> <span class="ow">in</span> <span class="nb">zip</span><span class="p">(</span><span class="nb">sorted</span><span class="p">(</span><span class="n">h1</span><span class="p">),</span> <span class="nb">sorted</span><span class="p">(</span><span class="n">h2</span><span class="p">))])</span>

    <span class="n">unique</span> <span class="o">=</span> <span class="n">collections</span><span class="o">.</span><span class="n">defaultdict</span><span class="p">(</span><span class="nb">list</span><span class="p">)</span>
    <span class="k">for</span> <span class="n">hkl1</span> <span class="ow">in</span> <span class="n">hkls</span><span class="p">:</span>
        <span class="n">found</span> <span class="o">=</span> <span class="kc">False</span>
        <span class="k">for</span> <span class="n">hkl2</span> <span class="ow">in</span> <span class="n">unique</span><span class="o">.</span><span class="n">keys</span><span class="p">():</span>
            <span class="k">if</span> <span class="n">is_perm</span><span class="p">(</span><span class="n">hkl1</span><span class="p">,</span> <span class="n">hkl2</span><span class="p">):</span>
                <span class="n">found</span> <span class="o">=</span> <span class="kc">True</span>
                <span class="n">unique</span><span class="p">[</span><span class="n">hkl2</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">hkl1</span><span class="p">)</span>
                <span class="k">break</span>
        <span class="k">if</span> <span class="ow">not</span> <span class="n">found</span><span class="p">:</span>
            <span class="n">unique</span><span class="p">[</span><span class="n">hkl1</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">hkl1</span><span class="p">)</span>

    <span class="n">pretty_unique</span> <span class="o">=</span> <span class="p">{}</span>
    <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">unique</span><span class="o">.</span><span class="n">items</span><span class="p">():</span>
        <span class="n">pretty_unique</span><span class="p">[</span><span class="nb">sorted</span><span class="p">(</span><span class="n">v</span><span class="p">)[</span><span class="o">-</span><span class="mi">1</span><span class="p">]]</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">v</span><span class="p">)</span>

    <span class="k">return</span> <span class="n">pretty_unique</span></div>
</pre></div>

            <div class="clearer"></div>
          </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../../../../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="../../../../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="nav-item nav-item-0"><a href="../../../../index.html">pymatgen 2020.7.3 documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="../../../index.html" >Module code</a> &#187;</li>
          <li class="nav-item nav-item-2"><a href="../../../pymatgen.html" >pymatgen</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="">pymatgen.analysis.diffraction.core</a></li> 
      </ul>
    </div>

    <div class="footer" role="contentinfo">
        &#169; Copyright 2011, Pymatgen Development Team.
      Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 3.1.2.
    </div>
<div class="footer">This page uses <a href="http://analytics.google.com/">
Google Analytics</a> to collect statistics. You can disable it by blocking
the JavaScript coming from www.google-analytics.com.
<script type="text/javascript">
  (function() {
    var ga = document.createElement('script');
    ga.src = ('https:' == document.location.protocol ?
              'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    ga.setAttribute('async', 'true');
    document.documentElement.firstChild.appendChild(ga);
  })();
</script>
</div>

  </body>
</html>